#include "arabicedit.h"
#include <QKeyEvent>
#include "qgautil.h"

ArabicEdit::ArabicEdit(QWidget* parent/*=0*/)
    :QLineEdit(parent)
{
}





void ArabicEdit::keyPressEvent(QKeyEvent *event)
{
  /*  switch (event->key()) {
     case Qt::Key_Home:
         if (event->modifiers() & Qt::ControlModifier) {
             goToBeginningOfDocument();
         } else {
             goToBeginningOfLine();
         }
        break;
     case Qt::Key_End:
         ...
     default:

     }
*/
    QChar key = event->key();
   // key =  key.toUpper();
    if ((key.unicode() >= Qt::Key_A && key.unicode() <= Qt::Key_AsciiTilde)
        || (key.unicode() >= Qt::Key_Plus && key.unicode() <= Qt::Key_9)
        || (key.unicode() >= Qt::Key_Colon && key.unicode() <= Qt::Key_Question))
    {
    //QString sKey = "";
     ;
    QString stmp ;
    QGaUtil::instance()->GetArabic101KeyChar(event->text()[0], stmp);
   // stmp.append(0x0633);

//    QKeyEvent e(QEvent::KeyPress,0x0630,  Qt::NoModifier);
    //QWidget::keyPressEvent(event);
    QLineEdit::keyPressEvent(new QKeyEvent(QEvent::KeyPress,
                                           event->key(),
                                           Qt::NoModifier,
                                            stmp, false, stmp.length()));
    }
    else
    {
        QLineEdit::keyPressEvent(event);
    }
}
